package leetcode

func removeElement(nums []int, val int) int {
	count := len(nums)
	if count == 0 {
		return count
	}

	index := 0
	for i := 0; i < count; i++ {
		if nums[i] != val {
			nums[index] = nums[i]
			index++
		}
	}

	return index
}
